package cn.xiaye.httpserver;

import java.net.ServerSocket;
import java.net.Socket;

/**
 * 服务监听类
 * 
 * @author 王夏夜
 * 
 */
public class ServerListener {
	static ServerSocket ss = null;

	/**
	 * 启动监听
	 * 
	 * @throws Exception
	 */
	public static void listening() throws Exception {
		ss = new ServerSocket(Constant.PORT);
		while (true) {
			Socket sock = ss.accept();
			service(sock);
		}
	}

	/**
	 * 分配线程
	 * 
	 * @param sock
	 */
	public static void service(Socket sock) {
		ThreadSocket ts = new ThreadSocket(sock);
		ts.start();
	}
}
